package fichiers;


import Composite.Dossier;
import Composite.Element;
import images.TabsDeDroite;
import javax.swing.JTree;
import javax.swing.event.*;
import javax.swing.tree.*;
import principal.*;

public class ControleurSelectionArbres implements TreeSelectionListener{
    
    private TabsDeDroite lesTabs;
    private JTree arbre;
    
    public ControleurSelectionArbres(TabsDeDroite lesTabs,JTree arbre){
        
        this.arbre=arbre;
        this.lesTabs=lesTabs;
    }
    
    public void valueChanged(TreeSelectionEvent e) {
        
        TreePath path=e.getNewLeadSelectionPath();
        if(path!=null){
            MyDefaultMutableTreeNode noeud = (MyDefaultMutableTreeNode) path.getLastPathComponent();
            Element element=(Element)noeud.getUserObject();
            
            GestionnaireDeSelection.getInstance().setComposantSelectionne(arbre);
            if(element instanceof Dossier){


                lesTabs.getAdapteurJListVignettes().setModelAdapte((Dossier)element);
                lesTabs.getAdapteurJTableDetail().setModelAdapte((Dossier)element);    
                

            }
        }
    }
    
    
}